#include "gtest/gtest.h"
#include "../BaseUtil/MyTest.h"
#include "MyVideoTrace.h"
namespace MyVideoTrace {

class VoodooCameraInfoTest : public testing::Test {
protected:
    virtual void SetUp() {}
    virtual void TearDown() {}
};

TEST_F(VoodooCameraInfoTest, ParseLineOfCameraInfo) {
	string cameraText = "-1.0389537289	-2.3194857464	-8.7493854574	0.0154150703	-0.1090370274	0.9939181567	867.9712767198	1.0747673435	-13.3438037594	0.4125204470	920.4246475975	100.9680805179	0.0000000000	0.0000000000	0.0106666667	0.0100000000	640	480	0.0000000000	-0.0000000000	9.2594614064	40.4709964153	0.9998810815	0.0012381049	-0.0153717263	0.0004455124	0.9940369177	0.1090431463";
	VoodooCameraInfo camera;
	ASSERT_TRUE( camera.parseCameraText( cameraText ) );

	ASSERT_FLOAT_EQ( -1.0389537289f, camera.getCameraPositionX() );
	ASSERT_FLOAT_EQ( -2.3194857464f, camera.getCameraPositionY() );
	ASSERT_FLOAT_EQ( -8.7493854574f, camera.getCameraPositionZ() );

	ASSERT_FLOAT_EQ( 0.0154150703f, camera.getCameraAxisX() );
	ASSERT_FLOAT_EQ( -0.1090370274f, camera.getCameraAxisY() );
	ASSERT_FLOAT_EQ( 0.9939181567f, camera.getCameraAxisZ() );

	ASSERT_FLOAT_EQ( 867.9712767198f, camera.getCameraHorizonX() );
	ASSERT_FLOAT_EQ( 1.0747673435f, camera.getCameraHorizonY() );
	ASSERT_FLOAT_EQ( -13.3438037594f, camera.getCameraHorizonZ() );

	ASSERT_FLOAT_EQ( 0.4125204470f, camera.getCameraVerticalX() );
	ASSERT_FLOAT_EQ( 920.4246475975f, camera.getCameraVerticalY() );
	ASSERT_FLOAT_EQ( 100.9680805179f, camera.getCameraVerticalZ() );

	ASSERT_FLOAT_EQ( 0.0000000000f, camera.getRadialDistortionK3() );
	ASSERT_FLOAT_EQ( 0.0000000000f, camera.getRadialDistortionK5() );

	ASSERT_FLOAT_EQ( 0.0106666667f, camera.getPixelSizeX() );
	ASSERT_FLOAT_EQ( 0.0100000000f, camera.getPixelSizeY() );

	ASSERT_EQ( 640, camera.getImageSizeWidth() );
	ASSERT_EQ( 480, camera.getImageSizeHeight() );

	ASSERT_FLOAT_EQ( 0.0000000000f, camera.getPrincipalPointOffsetX() );
	ASSERT_FLOAT_EQ( -0.0000000000f, camera.getPrincipalPointOffsetY() );

	ASSERT_FLOAT_EQ( 9.2594614064f, camera.getForcalLength() );

	ASSERT_FLOAT_EQ( 40.4709964153f, camera.getHorizontalFieldOfView() );

	ASSERT_FLOAT_EQ( 0.9998810815f, camera.getRotationAxis0X() );
	ASSERT_FLOAT_EQ( 0.0012381049f, camera.getRotationAxis0Y() );
	ASSERT_FLOAT_EQ( -0.0153717263f, camera.getRotationAxis0Z() );

	ASSERT_FLOAT_EQ( 0.0004455124f, camera.getRotationAxis1X() );
	ASSERT_FLOAT_EQ( 0.9940369177f, camera.getRotationAxis1Y() );
	ASSERT_FLOAT_EQ( 0.1090431463, camera.getRotationAxis1Z() );
}

TEST_F(VoodooCameraInfoTest, IgnoreComments) {
	string commentText = "# Text export";

	VoodooCameraInfo camera;
	ASSERT_FALSE( camera.parseCameraText( commentText ) );
}


}
